blob: 3b52f7895ca324025ab27c1e3e05a2330bb58c0e [file] [log] [blame]
Daniel Stenberg7d24ce92001-11-01 09:12:35 +00001Updated: November 1, 2001 (http://curl.haxx.se/docs/faq.shtml)
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +00002 _ _ ____ _
3 ___| | | | _ \| |
4 / __| | | | |_) | |
5 | (__| |_| | _ <| |___
6 \___|\___/|_| \_\_____|
7
8FAQ
9
Daniel Stenbergc3318b42000-08-17 14:06:42 +000010 1. Philosophy
11 1.1 What is cURL?
12 1.2 What is libcurl?
13 1.3 What is cURL not?
14 1.4 When will you make curl do XXXX ?
Daniel Stenberga0eb52b2001-03-23 15:28:13 +000015 1.5 Who makes cURL?
16 1.6 What do you get for making cURL?
Daniel Stenbergc528dc52001-08-07 11:17:37 +000017 1.7 What about CURL from curl.com?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000018
Daniel Stenbergc3318b42000-08-17 14:06:42 +000019 2. Install Related Problems
20 2.1 configure doesn't find OpenSSL even when it is installed
21 2.1.1. native linker doesn't find openssl
22 2.1.2. only the libssl lib is missing
23 2.2 Does curl work/build with other SSL libraries?
24 2.3 Where can I find a copy of LIBEAY32.DLL?
25 2.4 Does cURL support Socks (RFC 1928) ?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000026
Daniel Stenbergc3318b42000-08-17 14:06:42 +000027 3. Usage Problems
28 3.1 curl: (1) SSL is disabled, https: not supported
29 3.2 How do I tell curl to resume a transfer?
30 3.3 Why doesn't my posting using -F work?
31 3.4 How do I tell curl to run custom FTP commands?
32 3.5 How can I disable the Pragma: nocache header?
33 3.6 Does curl support javascript, ASP, XML, XHTML or HTML version Y?
34 3.7 Can I use curl to delete/rename a file through FTP?
35 3.8 How do I tell curl to follow HTTP redirects?
Daniel Stenberg4c485992001-04-22 15:45:27 +000036 3.9 How do I use curl in PHP, Perl, Tcl, Ruby or Java?
Daniel Stenberg147a6732001-03-08 09:25:09 +000037 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP?
Daniel Stenberg88d14e92001-05-29 14:02:20 +000038 3.11 How do I POST with a different Content-Type?
Daniel Stenberg7d3daa52001-10-23 10:12:00 +000039 3.12 Why do FTP specific features over HTTP proxy fails?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000040
Daniel Stenbergc3318b42000-08-17 14:06:42 +000041 4. Running Problems
42 4.1 Problems connecting to SSL servers.
Daniel Stenberge26ee092001-01-15 10:26:37 +000043 4.2 Why do I get problems when I use & or % in the URL?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000044 4.3 How can I use {, }, [ or ] to specify multiple URLs?
45 4.4 Why do I get downloaded data even though the web page doesn't exist?
46 4.5 Why do I get return code XXX from a HTTP server?
47 4.5.1 "400 Bad Request"
48 4.5.2 "401 Unauthorized"
49 4.5.3 "403 Forbidden"
50 4.5.4 "404 Not Found"
51 4.5.5 "405 Method Not Allowed"
52 4.6 Can you tell me what error code 142 means?
Daniel Stenberg4c485992001-04-22 15:45:27 +000053 4.7 How do I keep user names and passwords secret in Curl command lines?
Daniel Stenberg09ba8562000-10-27 12:25:00 +000054 4.8 I found a bug!
Daniel Stenberg2c100372000-12-19 07:30:51 +000055 4.9 Curl can't authenticate to the server that requires NTLM?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000056
Daniel Stenbergc3318b42000-08-17 14:06:42 +000057 5. libcurl Issues
Daniel Stenberg7d09e512001-01-11 12:52:07 +000058 5.1 Is libcurl thread-safe?
Daniel Stenberga40b55d2000-11-22 07:27:26 +000059 5.2 How can I receive all data into a large memory chunk?
Daniel Stenberg2c100372000-12-19 07:30:51 +000060 5.3 How do I fetch multiple files with libcurl?
Daniel Stenberg910fc852000-12-30 11:48:51 +000061 5.4 Does libcurl do Winsock initing on win32 systems?
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +000062 5.5 Does CURLOPT_FILE and CURLOPT_INFILE work on win32 ?
Daniel Stenberg4c485992001-04-22 15:45:27 +000063 5.6 What about Keep-Alive or persistent connections?
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +000064
Daniel Stenbergc3318b42000-08-17 14:06:42 +000065 6. License Issues
66 6.1 I have a GPL program, can I use the libcurl library?
67 6.2 I have a closed-source program, can I use the libcurl library?
Daniel Stenberg31b8eea2000-08-23 07:27:00 +000068 6.3 I have a BSD licensed program, can I use the libcurl library?
69 6.4 I have a program that uses LGPL libraries, can I use libcurl?
70 6.5 Can I modify curl/libcurl for my program and keep the changes secret?
71 6.6 Can you please change the curl/libcurl license to XXXX?
Daniel Stenbergc3318b42000-08-17 14:06:42 +000072
73==============================================================================
74
751. Philosophy
76
77 1.1 What is cURL?
78
79 cURL (or simply just 'curl') is a command line tool for getting or sending
80 files using URL syntax. The name is a play on 'Client for URLs', originally
Daniel Stenberg09ba8562000-10-27 12:25:00 +000081 with URL spelled in uppercase to make it obvious it deals with URLs. The
82 fact it can also be pronounced 'see URL' also helped.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000083
Daniel Stenberg4c485992001-04-22 15:45:27 +000084 Curl supports a range of common Internet protocols, currently including
Daniel Stenbergd73d28a2001-08-23 11:12:07 +000085 HTTP, HTTPS, FTP, FTPS, GOPHER, LDAP, DICT, TELNET and FILE.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000086
Daniel Stenberg8e7b2612001-03-22 11:23:48 +000087 We spell it cURL or just curl. We pronounce it with an initial k sound:
88 [kurl].
Daniel Stenberg887e7282001-01-03 09:13:07 +000089
Daniel Stenbergc3318b42000-08-17 14:06:42 +000090 1.2 What is libcurl?
91
Daniel Stenbergbc5954f2001-03-23 08:16:24 +000092 libcurl is a reliable and portable library which provides you with an easy
Daniel Stenberg4c485992001-04-22 15:45:27 +000093 interface to a range of common Internet protocols.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000094
Daniel Stenbergbc5954f2001-03-23 08:16:24 +000095 You can use libcurl for free in your application even if it is commercial
96 or closed-source.
Daniel Stenbergc3318b42000-08-17 14:06:42 +000097
98 1.3 What is cURL not?
Daniel Stenberge9640b62000-08-02 07:17:56 +000099
Daniel Stenberg7d24ce92001-11-01 09:12:35 +0000100 Curl is *not* a wget clone even though that is a very common misconception.
101 Never, during curl's development, have we intended curl to replace wget or
102 compete on its market. Curl is targeted at single-shot file transfers.
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000103
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000104 Curl is not a web site mirroring program. If you wanna use curl to mirror
105 something: fine, go ahead and write a script that wraps around curl to make
106 it reality (like curlmirror.pl does).
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000107
Daniel Stenberg4c485992001-04-22 15:45:27 +0000108 Curl is not an FTP site mirroring program. Sure, get and send FTP with curl
109 but if you want systematic and sequential behavior you should write a
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000110 script (or write a new program that interfaces libcurl) and do it.
111
112 Curl is not a PHP tool, even though it works perfectly well when used from
113 or with PHP.
114
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000115 Curl is not a single-OS program. Curl exists, compiles, builds and runs
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000116 under a wide range of operating systems, including all modern Unixes (and a
117 bunch of older ones too), Windows, Amiga, BeOS, OS/2, OS X, QNX etc.
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000118
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000119 1.4 When will you make curl do XXXX ?
120
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000121 We love suggestions of what to change in order to make curl and libcurl
122 better. We do however believe in a few rules when it comes to the future of
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000123 curl:
124
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000125 * Curl is to remain a command line tool. If you want GUIs or fancy scripting
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000126 capabilities, you're free to write another tool that uses libcurl and that
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000127 offers this. There's no point in having a single tool that does every
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000128 imaginable thing. That's also one of the great advantages of having the
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000129 core of curl as a library.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000130
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000131 * We do not add things to curl that other small and available tools already
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000132 do very fine at the side. Curl's output is fine to pipe into another
133 program or redirect to another file for the next program to interpret.
134
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000135 * We focus on protocol related issues and improvements. If you wanna do more
Daniel Stenberg5f8e93d2000-10-25 07:41:58 +0000136 magic with the supported protocols than curl currently does, chances are
Daniel Stenberg7d24ce92001-11-01 09:12:35 +0000137 big we will agree. If you wanna add more protocols, we may very well
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000138 agree.
139
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000140 * If you want someone else to make all the work while you wait for us to
141 implement it for you, that is not a very friendly attitude. We spend a
142 considerable time already on maintaining and developing curl. In order to
143 get more out of us, you should consider trading in some of your time and
144 efforts in return.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000145
146 * If you write the code, chances are bigger that it will get into curl
147 faster.
148
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000149 1.5 Who makes cURL?
150
151 cURL and libcurl are not made by any single individual. Sure, Daniel
152 Stenberg writes the major parts, but various people's submissions are
153 important and crucial. Anyone can post their changes and improvements and
154 have them inserted in the main sources (of course on the condition that
155 developers agree on that the fixes are good).
156
157 The list of contributors in the bottom of the man page is only a small part
158 of all the people that every day provide us with bug reports, suggestions,
159 ideas and source code.
160
161 curl is developed by a community, with Daniel at the wheel.
162
163 1.6 What do you get for making cURL?
164
165 Project cURL is entirely free and open, without any commercial interests or
166 money involved. No person gets paid in any way for developing curl. We all
Daniel Stenberg4c485992001-04-22 15:45:27 +0000167 do this voluntarily on our spare time.
Daniel Stenberga0eb52b2001-03-23 15:28:13 +0000168
169 We get some help from companies. Contactor Data hosts the curl web site and
170 the main mailing list, Haxx owns the curl web site's domain and
171 sourceforge.net hosts several project tools we take advantage from like the
172 bug tracker, mailing lists and more.
173
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000174 If you feel you want to show support our project with a donation, a very
175 nice way of doing that would be to buy "gift certificates" at useful online
176 shopping sites, such as amazon.com or thinkgeek.com.
177
178 1.7 What about CURL from curl.com?
179
180 During the summer 2001, curl.com has been busy advertising their client-side
181 programming language for the web, named CURL.
182
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000183 We are in no way associated with curl.com or their CURL programming
184 language.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000185
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000186 Our project name curl has been in effective use since 1998. We were not the
Daniel Stenberg4045cd52001-08-07 21:21:24 +0000187 first computer related project to use the name "curl" and do not claim any
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000188 first-hand rights to the name.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000189
Daniel Stenberg81b6ebc2001-08-07 18:02:37 +0000190 We recognize that we will be living in parallel with curl.com and wish them
191 every success.
Daniel Stenbergc528dc52001-08-07 11:17:37 +0000192
Daniel Stenbergc3318b42000-08-17 14:06:42 +00001932. Install Related Problems
194
195 2.1. configure doesn't find OpenSSL even when it is installed
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000196
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000197 This may be because of several reasons.
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000198
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000199 2.1.1. native linker doesn't find openssl
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000200
Daniel Stenbergbfb16902000-08-17 11:42:59 +0000201 Affected platforms:
202 Solaris (native cc compiler)
203 HPUX (native cc compiler)
204 SGI IRIX (native cc compiler)
Daniel Stenberg13962ad2000-09-28 10:26:44 +0000205 SCO UNIX (native cc compiler)
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000206
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000207 When configuring curl, I specify --with-ssl. OpenSSL is installed in
208 /usr/local/ssl Configure reports SSL in /usr/local/ssl, but fails to find
209 CRYPTO_lock in -lcrypto
Daniel Stenberg7c37c6a2000-05-22 17:35:35 +0000210
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000211 Cause: The cc for this test places the -L/usr/local/ssl/lib AFTER
212 -lcrypto, so ld can't find the library. This is due to a bug in the GNU
213 autoconf tool.
214
215 Workaround: Specifying "LDFLAGS=-L/usr/local/ssl/lib" in front of
216 ./configure places the -L/usr/local/ssl/lib early enough in the command
217 line to make things work
218
Daniel Stenbergbfb16902000-08-17 11:42:59 +0000219 Solution submitted by: Bob Allison <allisonb@users.sourceforge.net>
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000220
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000221 2.1.2. only the libssl lib is missing
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000222
223 If all include files and the libcrypto lib is present, with only the
224 libssl being missing according to configure, this is mostly likely because
225 a few functions are left out from the libssl.
226
227 If the function names missing include RSA or RSAREF you can be certain
Daniel Stenberg4c485992001-04-22 15:45:27 +0000228 that this is because libssl requires the RSA and RSAREF libs to build.
Daniel Stenbergef34ad22000-06-02 12:45:23 +0000229
230 See the INSTALL file section that explains how to add those libs to
231 configure. Make sure that you remove the config.cache file before you
232 rerun configure with the new flags.
233
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000234 2.2. Does curl work/build with other SSL libraries?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000235
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000236 Curl has been written to use OpenSSL, although there should not be much
Daniel Stenberg26d1aac2001-02-16 13:41:09 +0000237 problems using a different library. If anyone does "port" curl to use a
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000238 different SSL library, we are of course very interested in getting the
239 patch!
Daniel Stenberge9640b62000-08-02 07:17:56 +0000240
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000241 2.3. Where can I find a copy of LIBEAY32.DLL?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000242
243 That is an OpenSSL binary built for Windows.
244
245 Curl uses OpenSSL to do the SSL stuff. The LIBEAY32.DLL is what curl needs
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000246 on a windows machine to do https://. Check out the curl web site to find
Daniel Stenberg4c485992001-04-22 15:45:27 +0000247 accurate and up-to-date pointers to recent OpenSSL DLLs and other binary
Daniel Stenberge9640b62000-08-02 07:17:56 +0000248 packages.
249
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000250 2.4. Does cURL support Socks (RFC 1928) ?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000251
Daniel Stenberg4c485992001-04-22 15:45:27 +0000252 No. Nobody has wanted it that badly yet. We appreciate patches that bring
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000253 this functionality.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000254
255
Daniel Stenbergc3318b42000-08-17 14:06:42 +00002563. Usage problems
Daniel Stenberge9640b62000-08-02 07:17:56 +0000257
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000258 3.1. curl: (1) SSL is disabled, https: not supported
Daniel Stenberge9640b62000-08-02 07:17:56 +0000259
260 If you get this output when trying to get anything from a https:// server,
261 it means that the configure script couldn't find all libs and include files
262 it requires for SSL to work. If the configure script fails to find them,
263 curl is simply built without SSL support.
264
265 To get the https:// support into a curl that was previously built but that
266 reports that https:// is not supported, you should dig through the document
267 and logs and check out why the configure script doesn't find the SSL libs
268 and/or include files.
269
270 Also, check out the other paragraph in this FAQ labeled "configure doesn't
271 find OpenSSL even when it is installed".
272
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000273 3.2. How do I tell curl to resume a transfer?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000274
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000275 Curl supports resumed transfers both ways on both FTP and HTTP.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000276
Daniel Stenberg887e7282001-01-03 09:13:07 +0000277 Try the -C option.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000278
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000279 3.3. Why doesn't my posting using -F work?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000280
281 You can't simply use -F or -d at your choice. The web server that will
282 receive your post assumes one of the formats. If the form you're trying to
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000283 "fake" sets the type to 'multipart/form-data', then and only then you must
Daniel Stenberge9640b62000-08-02 07:17:56 +0000284 use the -F type. In all the most common cases, you should use -d which then
285 causes a posting with the type 'application/x-www-form-urlencoded'.
286
Daniel Stenberg4c485992001-04-22 15:45:27 +0000287 This is described in some detail in the MANUAL and TheArtOfHttpScripting
288 documents, and if you don't understand it the first time, read it again
289 before you post questions about this to the mailing list. Also, try reading
290 through the mailing list archives for old postings and questions regarding
291 this.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000292
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000293 3.4. How do I tell curl to run custom FTP commands?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000294
295 You can tell curl to perform optional commands both before and/or after a
296 file transfer. Study the -Q/--quote option.
297
298 Since curl is used for file transfers, you don't use curl to just perform
Daniel Stenberg4c485992001-04-22 15:45:27 +0000299 FTP commands without transferring anything. Therefore you must always specify
Daniel Stenberge9640b62000-08-02 07:17:56 +0000300 a URL to transfer to/from even when doing custom FTP commands.
301
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000302 3.5. How can I disable the Pragma: nocache header?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000303
304 You can change all internally generated headers by adding a replacement with
305 the -H/--header option. By adding a header with empty contents you safely
306 disable that one. Use -H "Pragma:" to disable that specific header.
307
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000308 3.6. Does curl support javascript, ASP, XML, XHTML or HTML version Y?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000309
310 To curl, all contents are alike. It doesn't matter how the page was
Daniel Stenberg4c485992001-04-22 15:45:27 +0000311 generated. It may be ASP, PHP, Perl, shell-script, SSI or plain
Daniel Stenberge9640b62000-08-02 07:17:56 +0000312 HTML-files. There's no difference to curl and it doesn't even know what kind
313 of language that generated the page.
314
315 Javascript is slightly different since that is code embedded in the HTML
316 that is sent for the client to interpret and curl has no javascript
317 interpreter.
318
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000319 3.7. Can I use curl to delete/rename a file through FTP?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000320
Daniel Stenberg4c485992001-04-22 15:45:27 +0000321 Yes. You specify custom FTP commands with -Q/--quote.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000322
323 One example would be to delete a file after you have downloaded it:
324
325 curl -O ftp://download.com/coolfile -Q '-DELE coolfile'
326
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000327 3.8 How do I tell curl to follow HTTP redirects?
Daniel Stenberge9640b62000-08-02 07:17:56 +0000328
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000329 Curl does not follow so-called redirects by default. The Location: header
330 that informs the client about this is only interpreted if you're using the
331 -L/--location option. As in:
Daniel Stenberge9640b62000-08-02 07:17:56 +0000332
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000333 curl -L http://redirector.com
334
Daniel Stenberg4c485992001-04-22 15:45:27 +0000335 3.9 How do I use curl in PHP, Perl, Tcl, Ruby or Java?
Daniel Stenberg368e3522001-01-29 10:16:21 +0000336
Daniel Stenberg4c485992001-04-22 15:45:27 +0000337 There exist many language-interfaces for curl that integrates it better with
338 various languages. If you are fluid in a script language, you may very well
339 opt to use such an interface instead of using the command line tool.
340
341 At the time of writing, there are bindings for the five language mentioned
342 above, but chances are there are even more by the time you read this. Or you
Daniel Stenbergcab90bf2001-05-30 08:01:35 +0000343 may be able you write your own wrapper for a not-yet supported language!
Daniel Stenberg4c485992001-04-22 15:45:27 +0000344
345 Find out more about which languages that support curl directly, and how to
346 install and use them, in the libcurl section of the curl web site:
347
348 http://curl.haxx.se/libcurl/
349
Daniel Stenberg368e3522001-01-29 10:16:21 +0000350 PHP4 has the ability to use libcurl as an internal module if built with that
351 option enabled. You then get a set of extra functions that can be used
352 within your PHP programs. You find all details about those functions in the
353 curl section in the PHP manual, see the online version at:
354
355 http://www.php.net/manual/ref.curl.php
356
357 PHP also offers the option to run a command line, and then you can of course
358 invoke the curl tool using a command line. This is the way to use curl if
359 you're using PHP3 or PHP4 built without curl module support.
360
Daniel Stenberg147a6732001-03-08 09:25:09 +0000361 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP?
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000362
363 Curl adheres to the HTTP spec, which basically means you can play with *any*
Daniel Stenberg4c485992001-04-22 15:45:27 +0000364 protocol that is built on top of HTTP. Protocols such as SOAP, WEBDAV and
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000365 XML-RPC are all such ones. You can use -X to set custom requests and -H to
366 set custom headers (or replace internally generated ones).
367
368 Using libcurl or PHP's curl modules is just as fine and you'd just use the
369 proper library options to do the same.
370
Daniel Stenberg88d14e92001-05-29 14:02:20 +0000371 3.11 How do I POST with a different Content-Type?
372
373 You can always replace the internally generated headers with -H/--header.
374 To make a simple HTTP POST with text/xml as content-type, do something like:
375
376 curl -d "datatopost" -H "Content-Type: text/xml" [URL]
377
Daniel Stenberg50e9f8f2001-10-23 10:12:28 +0000378 3.12 Why do FTP specific features over HTTP proxy fail?
Daniel Stenberg7d3daa52001-10-23 10:12:00 +0000379
380 Because when you use a HTTP proxy, the protocol spoken on the network will
381 be HTTP, even if you specify a FTP URL. This effectively means that you
382 normally can't use FTP specific features such as ftp upload and ftp quote
383 etc.
384
385 There is one exception to this rule, and that is if you can "tunnel through"
386 the given HTTP proxy. Proxy tunneling is enabled with a special option (-P)
387 and is generally not available as proxy admins usuable disable tunneling to
388 other ports than 443 (which is used for HTTPS access through proxies).
389
Daniel Stenbergc3318b42000-08-17 14:06:42 +00003904. Running Problems
391
392 4.1. Problems connecting to SSL servers.
Daniel Stenberge9640b62000-08-02 07:17:56 +0000393
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000394 It took a very long time before we could sort out why curl had problems to
395 connect to certain SSL servers when using SSLeay or OpenSSL v0.9+. The
396 error sometimes showed up similar to:
Daniel Stenberge9640b62000-08-02 07:17:56 +0000397
398 16570:error:1407D071:SSL routines:SSL2_READ:bad mac decode:s2_pkt.c:233:
399
400 It turned out to be because many older SSL servers don't deal with SSLv3
401 requests properly. To correct this problem, tell curl to select SSLv2 from
402 the command line (-2/--sslv2).
403
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000404 There has also been examples where the remote server didn't like the SSLv2
Daniel Stenberge9640b62000-08-02 07:17:56 +0000405 request and instead you had to force curl to use SSLv3 with -3/--sslv3.
406
Daniel Stenberge26ee092001-01-15 10:26:37 +0000407 4.2. Why do I get problems when I use & or % in the URL?
Daniel Stenberg29470102000-06-02 13:32:01 +0000408
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000409 In general unix shells, the & letter is treated special and when used, it
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000410 runs the specified command in the background. To safely send the & as a part
Daniel Stenberg4c485992001-04-22 15:45:27 +0000411 of a URL, you should quote the entire URL by using single (') or double (")
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000412 quotes around it.
Daniel Stenberg29470102000-06-02 13:32:01 +0000413
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000414 An example that would invoke a remote CGI that uses &-letters could be:
Daniel Stenberg8f037322000-06-06 14:09:01 +0000415
Daniel Stenbergedcd5df2000-06-06 14:13:36 +0000416 curl 'http://www.altavista.com/cgi-bin/query?text=yes&q=curl'
Daniel Stenberg8f037322000-06-06 14:09:01 +0000417
Daniel Stenberge26ee092001-01-15 10:26:37 +0000418 In win32, the standard DOS shell treats the %-letter specially and you may
419 need to quote the string properly when % is used in it.
420
Daniel Stenberg1b77c182001-01-29 10:24:51 +0000421 Also note that if you want the literal %-letter to be part of the data you
422 pass in a POST using -d/--data you must encode it as '%25'.
423
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000424 4.3. How can I use {, }, [ or ] to specify multiple URLs?
Daniel Stenberg29470102000-06-02 13:32:01 +0000425
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000426 Because those letters have a special meaning to the shell, and to be used in
427 a URL specified to curl you must quote them.
Daniel Stenberg29470102000-06-02 13:32:01 +0000428
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000429 An example that downloads two URLs (sequentially) would do:
Daniel Stenberg8f037322000-06-06 14:09:01 +0000430
Daniel Stenbergedcd5df2000-06-06 14:13:36 +0000431 curl '{curl,www}.haxx.se'
Daniel Stenberg8f037322000-06-06 14:09:01 +0000432
Daniel Stenberge26ee092001-01-15 10:26:37 +0000433 To be able to use those letters as actual parts of the URL (without using
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000434 them for the curl URL "globbing" system), use the -g/--globoff option (curl
435 7.6 and later):
Daniel Stenberge26ee092001-01-15 10:26:37 +0000436
437 curl -g 'www.site.com/weirdname[].html'
438
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000439 4.4. Why do I get downloaded data even though the web page doesn't exist?
Daniel Stenberg29470102000-06-02 13:32:01 +0000440
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000441 Curl asks remote servers for the page you specify. If the page doesn't exist
442 at the server, the HTTP protocol defines how the server should respond and
443 that means that headers and a "page" will be returned. That's simply how
444 HTTP works.
Daniel Stenberg29470102000-06-02 13:32:01 +0000445
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000446 By using the --fail option you can tell curl explicitly to not get any data
447 if the HTTP return code doesn't say success.
Daniel Stenberg8f037322000-06-06 14:09:01 +0000448
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000449 4.5 Why do I get return code XXX from a HTTP server?
Daniel Stenberg29470102000-06-02 13:32:01 +0000450
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000451 RFC2616 clearly explains the return codes. This is a short transcript. Go
452 read the RFC for exact details:
Daniel Stenberg29470102000-06-02 13:32:01 +0000453
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000454 4.5.1 "400 Bad Request"
Daniel Stenberg29470102000-06-02 13:32:01 +0000455
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000456 The request could not be understood by the server due to malformed
457 syntax. The client SHOULD NOT repeat the request without modifications.
458
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000459 4.5.2 "401 Unauthorized"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000460
461 The request requires user authentication.
462
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000463 4.5.3 "403 Forbidden"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000464
465 The server understood the request, but is refusing to fulfill it.
466 Authorization will not help and the request SHOULD NOT be repeated.
467
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000468 4.5.4 "404 Not Found"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000469
470 The server has not found anything matching the Request-URI. No indication
471 is given of whether the condition is temporary or permanent.
472
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000473 4.5.5 "405 Method Not Allowed"
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000474
475 The method specified in the Request-Line is not allowed for the resource
476 identified by the Request-URI. The response MUST include an Allow header
477 containing a list of valid methods for the requested resource.
478
479 4.6. Can you tell me what error code 142 means?
Daniel Stenberg29470102000-06-02 13:32:01 +0000480
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000481 All error codes that are larger than the highest documented error code means
Daniel Stenberg13bf9642001-08-23 11:11:13 +0000482 that curl has exited due to a crash. This is a serious error, and we
483 appriciate a detailed bug report from you that describes how we could go
484 ahead and repeat this!
Daniel Stenberg29470102000-06-02 13:32:01 +0000485
Daniel Stenberg4c485992001-04-22 15:45:27 +0000486 4.7. How do I keep user names and passwords secret in Curl command lines?
Daniel Stenberg29470102000-06-02 13:32:01 +0000487
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000488 This problem has two sides:
Daniel Stenberg29470102000-06-02 13:32:01 +0000489
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000490 The first part is to avoid having clear-text passwords in the command line
491 so that they don't appear in 'ps' outputs and similar. That is easily
Daniel Stenberg4c485992001-04-22 15:45:27 +0000492 avoided by using the "-K" option to tell curl to read parameters from a
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000493 file or stdin to which you can pass the secret info.
Daniel Stenberg29470102000-06-02 13:32:01 +0000494
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000495 To keep the passwords in your account secret from the rest of the world is
496 not a task that curl addresses. You could of course encrypt them somehow to
497 at least hide them from being read by human eyes, but that is not what
498 anyone would call security.
Daniel Stenberg29470102000-06-02 13:32:01 +0000499
Daniel Stenberg887e7282001-01-03 09:13:07 +0000500 Also note that regular HTTP and FTP passwords are sent in clear across the
501 network. All it takes for anyone to fetch them is to listen on the network.
Daniel Stenberg4c485992001-04-22 15:45:27 +0000502 Eavesdropping is very easy.
Daniel Stenberg887e7282001-01-03 09:13:07 +0000503
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000504 4.8 I found a bug!
505
Daniel Stenberg4c485992001-04-22 15:45:27 +0000506 It is not a bug if the behavior is documented. Read the docs first.
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000507
508 If it is a problem with a binary you've downloaded or a package for your
509 particular platform, try contacting the person who built the package/archive
510 you have.
511
512 If there is a bug, post a bug report in the Curl Bug Track System over at
Daniel Stenberg9012f8c2001-01-15 10:28:41 +0000513 http://sourceforge.net/bugs/?group_id=976
Daniel Stenberg09ba8562000-10-27 12:25:00 +0000514
515 Always include as many details you can think of, including curl version,
516 operating system name and version and complete instructions how to repeat
517 the bug.
518
Daniel Stenberg2c100372000-12-19 07:30:51 +0000519 4.9. Curl can't authenticate to the server that requires NTLM?
520
521 NTLM is a Microsoft proprietary protocol. Unfortunately, curl does not
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000522 currently support that. Proprietary formats are evil. You should not use
523 such ones.
Daniel Stenberg29470102000-06-02 13:32:01 +0000524
Daniel Stenbergc3318b42000-08-17 14:06:42 +00005255. libcurl Issues
Daniel Stenberg29470102000-06-02 13:32:01 +0000526
Daniel Stenberg7d09e512001-01-11 12:52:07 +0000527 5.1. Is libcurl thread-safe?
Daniel Stenberg29470102000-06-02 13:32:01 +0000528
Daniel Stenberg7d09e512001-01-11 12:52:07 +0000529 Yes.
530
531 We have written the libcurl code specificly adjusted for multi-threaded
532 programs. libcurl will use thread-safe functions instead of non-safe ones if
533 your system has such.
Daniel Stenberg29470102000-06-02 13:32:01 +0000534
Daniel Stenberg4c485992001-04-22 15:45:27 +0000535 We would appreciate some kind of report or README file from those who have
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000536 used libcurl in a threaded environment.
Daniel Stenberg29470102000-06-02 13:32:01 +0000537
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000538 5.2 How can I receive all data into a large memory chunk?
539
Daniel Stenberga84af982001-05-15 13:09:27 +0000540 [ See also the examples/getinmemory.c source ]
541
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000542 You are in full control of the callback function that gets called every time
543 there is data received from the remote server. You can make that callback do
Daniel Stenberg4c485992001-04-22 15:45:27 +0000544 whatever you want. You do not have to write the received data to a file.
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000545
546 One solution to this problem could be to have a pointer to a struct that you
547 pass to the callback function. You set the pointer using the
548 curl_easy_setopt(CURLOPT_FILE) function. Then that pointer will be passed to
549 the callback instead of a FILE * to a file:
550
551 /* imaginary struct */
552 struct MemoryStruct {
553 char *memory;
554 size_t size;
555 };
556
557 /* imaginary callback function */
558 size_t
559 WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
560 {
561 register int realsize = size * nmemb;
562 struct MemoryStruct *mem = (struct MemoryStruct *)data;
563
564 mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
565 if (mem->memory) {
566 memcpy(&(mem->memory[mem->size]), ptr, realsize);
567 mem->size += realsize;
568 mem->memory[mem->size] = 0;
569 }
570 return realsize;
571 }
572
Daniel Stenberg2c100372000-12-19 07:30:51 +0000573 5.3 How do I fetch multiple files with libcurl?
Daniel Stenbergec5ac822000-12-14 08:37:09 +0000574
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000575 Starting with version 7.7, curl and libcurl will have excellent support for
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000576 transferring multiple files. You should just repeatedly set new URLs with
577 curl_easy_setopt() and then transfer it with curl_easy_perform(). The handle
578 you get from curl_easy_init() is not only reusable starting with libcurl
579 7.7, but also you're encouraged to reuse it if you can, as that will enable
Daniel Stenberg4c485992001-04-22 15:45:27 +0000580 libcurl to use persistent connections.
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000581
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000582 For libcurl prior to 7.7, there was no multiple file support. The only
583 available way to do multiple requests was to init/perform/cleanup for each
584 transfer.
Daniel Stenberga40b55d2000-11-22 07:27:26 +0000585
Daniel Stenbergbc5954f2001-03-23 08:16:24 +0000586 5.4 Does libcurl do Winsock initialization on win32 systems?
Daniel Stenberg910fc852000-12-30 11:48:51 +0000587
Daniel Stenberg6d213e22001-11-01 14:51:02 +0000588 Yes (since 7.8.1) if told to in the curl_global_init() call.
Daniel Stenberg910fc852000-12-30 11:48:51 +0000589
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +0000590 5.5 Does CURLOPT_FILE and CURLOPT_INFILE work on win32 ?
Daniel Stenberg41084e52001-01-22 08:42:00 +0000591
592 Yes, but you cannot open a FILE * and pass the pointer to a DLL and have
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +0000593 that DLL use the FILE *. If you set CURLOPT_FILE you must also use
594 CURLOPT_WRITEFUNCTION as well to set a function that writes the file, even
595 if that simply writes the data to the specified FILE*. Similarly, if you use
596 CURLOPT_INFILE you must also specify CURLOPT_READFUNCTION.
Daniel Stenberg41084e52001-01-22 08:42:00 +0000597
Daniel Stenberg5d7b32d2001-02-04 20:08:42 +0000598 (Provided by Joel DeYoung and Bob Schader)
Daniel Stenberg41084e52001-01-22 08:42:00 +0000599
Daniel Stenberg4c485992001-04-22 15:45:27 +0000600 5.6 What about Keep-Alive or persistent connections?
Daniel Stenberg6dc5c6f2001-01-27 20:51:31 +0000601
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000602 Starting with version 7.7, curl and libcurl will have excellent support for
Daniel Stenberg4c485992001-04-22 15:45:27 +0000603 persistent connections when transferring several files from the same server.
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000604 Curl will attempt to reuse connections for all URLs specified on the same
605 command line/config file, and libcurl will reuse connections for all
606 transfers that are made using the same libcurl handle.
Daniel Stenberg5dd0a8a2001-03-06 14:37:37 +0000607
Daniel Stenberg4c485992001-04-22 15:45:27 +0000608 Previous versions had no persistent connection support.
Daniel Stenberg6dc5c6f2001-01-27 20:51:31 +0000609
Daniel Stenbergc3318b42000-08-17 14:06:42 +00006106. License Issues
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000611
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000612 Curl and libcurl are released under a MIT/X derivate license *or* the MPL,
613 the Mozilla Public License. To get a really good answer to your license
614 conflict questions, you should study the MPL and MIT/X licenses and the
615 license you are about to use and check for clashes yourself. This section is
616 just a brief summary for the cases we get the most questions. (Parts of this
617 section was much enhanced by Bjorn Reese.)
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000618
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000619 6.1. I have a GPL program, can I use the libcurl library?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000620
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000621 Yes!
Daniel Stenberg7d1ef962000-08-14 06:31:59 +0000622
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000623 Since libcurl may be distributed under the MIT/X derivate license, it can be
624 used together with GPL in any software.
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000625
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000626 6.2. I have a closed-source program, can I use the libcurl library?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000627
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000628 Yes!
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000629
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000630 libcurl does not put any restrictions on the program that uses the library.
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000631
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000632 6.3. I have a BSD licensed program, can I use the libcurl library?
633
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000634 Yes!
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000635
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000636 libcurl does not put any restrictions on the program that uses the library.
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000637
638 6.4. I have a program that uses LGPL libraries, can I use libcurl?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000639
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000640 Yes!
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000641
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000642 The LGPL license doesn't clash with other licenses.
Daniel Stenbergc3318b42000-08-17 14:06:42 +0000643
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000644 6.5. Can I modify curl/libcurl for my program and keep the changes secret?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000645
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000646 Yes!
Daniel Stenberg0d181b52001-01-04 12:43:53 +0000647
648 The MIT/X derivate license practically allows you to do almost anything with
649 the sources, on the condition that the copyright texts in the sources are
650 left intact.
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000651
Daniel Stenberg31b8eea2000-08-23 07:27:00 +0000652 6.6. Can you please change the curl/libcurl license to XXXX?
Daniel Stenbergc3c77392000-07-31 22:42:34 +0000653
Daniel Stenbergc59baa02001-02-12 10:05:09 +0000654 No.
655
Daniel Stenberg11d718b2001-03-13 11:47:30 +0000656 We have carefully picked this license after years of development and
657 discussions and a large amount of people have contributed with source code
658 knowing that this is the license we use. This license puts the restrictions
659 we want on curl/libcurl and it does not spread to other programs or
660 libraries that use it. The recent dual license modification should make it
661 possible for everyone to use libcurl or curl in their projects, no matter
662 what license they already have in use.